//
// Copyright (C) [2024] Xingyun Integrated Circuit, Inc.
//
// GreenCode was a private technology asset of Xingyun Integrated Circuit， Inc （Confidential）
//  Author: Shawn.Tan
//  Date : 2025.10.28
//
//  History : Initial Version 2025.10.28
//
//
#ifndef Green_PageTableAllocator_H
#define Green_PageTableAllocator_H

#include "Defines.h"
#include "Enums.h"
#include ARCH_ENUM_HEADER

namespace Green {

  class ConstraintSet;

  /*!
    \class PageTableAllocator
    \brief This class manages page table allocated.
  */

  class PageTableAllocator {
  public:
    explicit PageTableAllocator(EMemBankType bankType); //!< Constructor with memory bank type given.
    ~PageTableAllocator(); //!< Destructor.

    bool AllocatePageTableBlock(uint64 align, uint64 size, const ConstraintSet* usable, const ConstraintSet* range, uint64& start); //!< Allocate page table with align and size specified.
    inline const ConstraintSet* Allocated() const { return mpAllocated; } //!< Return const pointer to allocate ConstraintSet.

    ASSIGNMENT_OPERATOR_ABSENT(PageTableAllocator);
    COPY_CONSTRUCTOR_ABSENT(PageTableAllocator);
  protected:
    PageTableAllocator() : mMemoryBank(EMemBankType(0)), mpAllocated(nullptr) { } //!< Default constructor.
  protected:
    EMemBankType mMemoryBank; //!< Memory bank for the page tables.
    ConstraintSet* mpAllocated; //!< Allocated page table regions.
  };

}

#endif
